package org.sxp.datax.executor.util;

import cn.hutool.core.io.FileUtil;
import com.xxl.job.core.biz.model.PPJobTmpParam;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.IJobHandler;
import org.springframework.util.CollectionUtils;

import java.io.File;

/**
 * @author shenxingping
 * @date 2022/01/15
 */
public class PPJobKillUtil {
    public static void killJob(int jobId){
        PPJobTmpParam jobTmpParam = IJobHandler.jobTmpFiles.get(String.valueOf(jobId));
        if(jobTmpParam != null){
            boolean result = ProcessUtil.killProcessByPid(jobTmpParam.getProcessId());
            if(result){
                XxlJobHelper.log("DataX进程终止成功!!!进程ID={}", jobTmpParam.getProcessId());
            }else{
                XxlJobHelper.log("DataX进程终止失败!!!进程ID={}", jobTmpParam.getProcessId());
            }
        }
    }
}
